import BNodeDecorator from "../base/BNodeDecorator";
import {ActionResult} from "../BTreeActionResult";
const {ccclass, property} = cc._decorator;
//<Tree-Category>{"path":"decorators","color":"#fff419","tip":""}</Tree-Category>
@ccclass
/**
 * 结果翻转
 */
export default class BNodeInverter extends BNodeDecorator {

    public excute(): ActionResult {
        if (!this.child) {
            return ActionResult.ERROR;
        }
        var status = this.child.runNode();
        if (status == ActionResult.SUCCESS)
            status = ActionResult.FAILURE;
        else if (status == ActionResult.FAILURE)
            status = ActionResult.SUCCESS;

        return status;
    }
}
